/**
 * 
 */
package de.cbf.cam.dsa.tavern.carte.ui;

import java.awt.event.ActionListener;
import java.util.Iterator;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;

import de.cbf.cam.dsa.tavern.carte.model.entities.Ingredient;
import de.cbf.cam.dsa.tavern.carte.model.entities.Processing;
import de.cbf.cam.dsa.tavern.carte.model.entities.interfaces.IEditableEntity;

/**
 * @author Stefan Alter
 *
 */
public class CompositeEditProcessing extends AbstractCompositeEditEntity {
	private CompositeEditProcessingData compositeEditData;
	/**
	 * @param parent
	 * @param style
	 */
	public CompositeEditProcessing(Composite parent, int style) {
		super(parent, style);		
	}

	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.tavern.carte.ui.interfaces.ICompositeEditEntity#clear()
	 */
	@Override
	public void clear() {
		compositeEditData.clearData();
	}
	@Override
	public void setEnabled(boolean enabled) {
		compositeEditData.setEnabled(enabled);
		super.setEnabled(enabled);
	}
	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.tavern.carte.ui.AbstractCompositeEditEntity#checkEntity(de.cbf.cam.dsa.tavern.carte.model.entities.interfaces.IEditableEntity)
	 */
	@Override
	protected boolean checkEntity(IEditableEntity value) {
		if (value instanceof Processing) {
			return true;			
		}
		return false;
	}

	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.tavern.carte.ui.AbstractCompositeEditEntity#setEntityData(de.cbf.cam.dsa.tavern.carte.model.entities.interfaces.IEditableEntity)
	 */
	@Override
	protected void setEntityData(IEditableEntity value) {
		compositeEditData.setEntityData(value);
	}

	/* (non-Javadoc)
	 * @see de.cbf.cam.dsa.tavern.carte.ui.AbstractCompositeEditEntity#createCompositeEntity(org.eclipse.swt.widgets.Composite)
	 */
	@Override
	protected Composite createCompositeEntity(Composite parent) {
		compositeEditData = new CompositeEditProcessingData(parent, SWT.NONE); 
		return compositeEditData;
	}
	
//	=========================================
//		through to data composite
//	=========================================
	//Properties
	public String getProcessingName(){
		return compositeEditData.getProcessingName();
	}
	public Double getPrice(){
		return compositeEditData.getPrice();
	}	
	public Ingredient getSelectedIngredient(){
		return compositeEditData.getSelectedIngredient();
	}
	public String getSelectedAddendumCategory(){
		return compositeEditData.getSelectedAddendumCategory();
	}	
	public void setButtonFromAddendumsEnabled(boolean value) {
		compositeEditData.setButtonFromAddendumsEnabled(value);
	}
	public void setButtonToAddendumsEnabled(boolean value) {
		compositeEditData.setButtonToAddendumsEnabled(value);
	}	
	public void setIngredients(Iterator<Ingredient> iteratorIngredients) {
		compositeEditData.setIngredients(iteratorIngredients);		
	}
	//listeners
	public boolean registerNameModifyListener(ActionListener listener){
		return compositeEditData.registerNameModifyListener(listener);
	}
	public boolean deRegisterNameModifyListener(ActionListener listener){
		return compositeEditData.deRegisterNameModifyListener(listener);
	}
	public boolean registerPriceModifyListener(ActionListener listener){
		return compositeEditData.registerPriceModifyListener(listener);
	}
	public boolean deRegisterPriceModifyListener(ActionListener listener){
		return compositeEditData.deRegisterPriceModifyListener(listener);
	}
	public boolean registerAddToAddendumsListener(ActionListener listener){
		return compositeEditData.registerAddToAddendumsListener(listener);
	}
	public boolean deRegisterAddToAddendumsListener(ActionListener listener){
		return compositeEditData.deRegisterAddToAddendumsListener(listener);
	}
	public boolean registerRemoveFromAddendumsListener(ActionListener listener){
		return compositeEditData.registerRemoveFromAddendumsListener(listener);
	}
	public boolean deRegisterRemoveFromAddendumsListener(ActionListener listener){
		return compositeEditData.deRegisterRemoveFromAddendumsListener(listener);
	}
	public boolean registerIngredientSelectionListener(ActionListener listener){
		return compositeEditData.registerIngredientSelectionListener(listener);
	}
	public boolean deRegisterIngredientSelectionListener(ActionListener listener){
		return compositeEditData.deRegisterIngredientSelectionListener(listener);
	}
	public boolean registerCategorySelectionListener(ActionListener listener){
		return compositeEditData.registerCategorySelectionListener(listener);
	}
	public boolean deRegisterCategorySelectionListener(ActionListener listener){
		return compositeEditData.deRegisterCategorySelectionListener(listener);
	}

	

}
